package mvp.com.bbc.rcjavaretrofitdaggermvp.mvp.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import mvp.com.bbc.rcjavaretrofitdaggermvp.R;
import mvp.com.bbc.rcjavaretrofitdaggermvp.baseAF.BaseFragment;
import mvp.com.bbc.rcjavaretrofitdaggermvp.mvp.adapter.BaseFrgamenAdapter;

/**
 * Created by ${cbf} on 2017/11/25.
 */

public class HomePageFragment extends BaseFragment {
    @BindView(R.id.tablayout)
    TabLayout tablayout;
    @BindView(R.id.vp)
    ViewPager vp;
    String[] title = new String[]{"全部", "热门", "推荐","我的问答"};

    @Override
    protected int setContentLayout() {
        return R.layout.base_viewpager_tab;
    }

    @Override
    protected void findViews() {
    }

    @Override
    protected void init() {
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(HomeFragment.Instance("1"));
        fragments.add(HomeFragment.Instance("2"));
        fragments.add(HomeFragment.Instance("3"));
        fragments.add(HomeFragment.Instance("4"));
        BaseFrgamenAdapter adapter = new BaseFrgamenAdapter(getChildFragmentManager(), fragments, title);
        vp.setAdapter(adapter);
        tablayout.setupWithViewPager(vp);

    }

    @Override
    protected void setListeners() {

    }

    @Override
    public void onClick(View view) {

    }

    public static HomePageFragment Instance(Context context, String home) {
        HomePageFragment homeFragment = new HomePageFragment();
        Bundle bundle = new Bundle();
        bundle.putString("name", home);
        homeFragment.setArguments(bundle);
        return homeFragment;
    }

    @Override
    public void onEvent(String action) {
        super.onEvent(action);
        if (action.equals("刷新数据")) {
//            tablayout.se
        }
    }
}
